from hep.aida import *

from java.lang import *
from java.util import *
from java.io import *

from jhplot  import *

from fr.in2p3.ipnl.oflap.scint import *

Locale.setDefault(Locale.ENGLISH)
System.getProperties().setProperty("hep.aida.BatchAnalysisFactory","hep.aida.ref.BatchAnalysisFactory")


""" Queens DPS """
lyComp = []
kinComp = []
treeQ = AidaFileReader("/home/marc-antoine/Dropbox/BGO","ScintillationAnalysis_BGO_QFile").tree
outPath = "/home/marc-antoine/Dropbox/BGO/"
lyName = "LY_Q_Comp#"
kinName = "Decay_Q_Comp#"
for i in range(4):
	#lyComp.append(P1D(GrabDPS(treeQ, "/Light_Yield/" + lyName + String.valueOf(i)).dps))
	lyComp.append(P1D(GrabIObject(treeQ, "/Light_Yield/" + lyName + String.valueOf(i)).dps))
	lyComp[i].toFile(outPath + lyName + String.valueOf(i) + ".txt")
	print("Writing text file: " + lyName + String.valueOf(i) + ".txt")
	
	#kinComp.append(P1D(GrabDPS(treeQ, "/Kinetic/" + kinName + String.valueOf(i)).dps))
	kinComp.append(P1D(GrabIObject(treeQ, "/Kinetic/" + kinName + String.valueOf(i)).dps))
	kinComp[i].toFile(outPath + kinName + String.valueOf(i) + ".txt")
	print("Writing text file: "+ kinName + String.valueOf(i) + ".txt")
	#
	#lyComp.append(P1D(afrQ.getDPS("/Light_Yield/" + lyName + String.valueOf(i))))
	#lyComp[i].toFile(outPath + lyName + String.valueOf(i) + ".txt")
	#print("Writing text file: " + lyName + String.valueOf(i) + ".txt")
	#
	#kinComp.append(P1D(afrQ.getDPS("/Kinetic/" + kinName + String.valueOf(i))))
	#lyComp[i].toFile(outPath + kinName + String.valueOf(i) + ".txt")
	#print("Writing text file: "+ kinName + String.valueOf(i) + ".txt")

print("That's all folks !")

